package com.hidt.shop.controller;

import com.fasterxml.jackson.core.io.JsonEOFException;
import com.hidt.shop.domain.Goods;
import com.hidt.shop.service.SelectGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@ResponseBody
public class SelectGoodsController {

    @Autowired
   private  SelectGoodsService  selectGoodsService;


/**
 *@methodName selectGoodsByNameAndPrice
 *@方法功能描述
 * 对商品名字模糊
 * 对价格区间查询
 * 分页显示
 * 需要 good_name
 * min_price
 * max_price
 * start  pageSize
 *@params
 * @param map
 *@return java.util.List<com.hidt.shop.domain.Goods>
 *@exception
 *@author $風~$
 *@Date 2021/1/20
 */
    @RequestMapping("/selectGoodsByNameAndPrice")
    public List<Goods> selectGoodsByNameAndPrice(@RequestBody Map<String,String> map) {
        System.out.println("通过商品名查询~~~~~~~~~~~~~~~~~");
        System.out.println(map);
        int pageSize = Integer.parseInt(map.get("pageSize"));
        int pageNum = Integer.parseInt(map.get("start"));
        int start = (pageNum - 1) * pageSize;
        List<Goods> goodsList = selectGoodsService.selectGoodsByNameAndPrice(map,start,pageSize);
        return goodsList;
    }

}
